package com.disc.baidu;


import com.disc.common.Constant;
import com.disc.util.BaseUtil;
import com.disc.util.HttpUtil;
import com.disc.util.JsUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.ArrayList;
import java.util.List;

public class BaiduPanService extends BaseClass{

   public String  getFileDownloadUrl(String fileUrl)  throws Exception
   {

      String url = Constant.BAIDU_FILE_DOWNLOAD_URL;
      List<NameValuePair> nvps = new ArrayList<>();
      nvps.add(new BasicNameValuePair("logid",JsUtil.getLogid(this.baiDuLogin.baiduId)));
      nvps.add(new BasicNameValuePair("time",BaseUtil.getBaiDuTimes()));
      nvps.add(new BasicNameValuePair("rand",BaseUtil.getFixLenthString(40)));
      nvps.add(new BasicNameValuePair("path",fileUrl));
      nvps.add(new BasicNameValuePair("bdstoken",this.baiDuLogin.token));
      url += getEncodedUrl(nvps);
      return HttpUtil.createHttpGet(url,baiDuLogin.httpclient);
   }
}
